<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>回调</title>

	<!--集成vue和axios，还要axios全局配置（导入common.js）-->
	<!--script src方式引入vue和axios-->
	<!--全局使用-->
	<script src="js/plugins/vue/dist/vue.js"></script>

	<script src="js/plugins/axios/dist/axios.js"></script>

	<script src="js/common.js"></script>
</head>
<body>
<div id="myDiv">

</div>
<script type="text/javascript">
	new Vue({
		el:"#myDiv",
		mounted(){
			//解析参数对象
			let url = location.href;
			let paramObj = parseUrlParams2Obj(url);


			//发起微信登录请求
			this.$http.post("/login/wechat",{"code":paramObj.code})
					.then(result=>{
						result = result.data;//AjaxResult
						if(result.success){//说明是第2---n次扫码，直接登录成功
							localStorage.setItem("token",result.resultObj.token);//UUID的随机串
							//注意：需要将返回的JSON对象转换成JSON字符串存储
							localStorage.setItem("logininfo",JSON.stringify(result.resultObj.logininfo));
							//登录成功，跳转到首页
							location.href = "index.html";
						}else{//跳转到绑定页面
							let binderUrl = "binder.html"+result.resultObj;
							location.href = binderUrl;
						}
					})
					.catch(result=>{
						alert("系统错误");
						console.log(result);
					})
		}
	});
</script>
</body>
</html>